// 工作流 API
interface BrushNetLoader {
  inputs: {
    brushnet: string;
    dtype: string;
  };
  class_type: 'BrushNetLoader';
  _meta: {
    title: string;
  };
}

interface KSampler {
  inputs: {
    seed: number;
    steps: number;
    cfg: number;
    sampler_name: string;
    scheduler: string;
    denoise: number;
    model: [string, number];
    positive: [string, number];
    negative: [string, number];
    latent_image: [string, number];
  };
  class_type: 'KSampler';
  _meta: {
    title: string;
  };
}

interface VAEDecode {
  inputs: {
    samples: [string, number];
    vae: [string, number];
  };
  class_type: 'VAEDecode';
  _meta: {
    title: string;
  };
}

interface BrushNet {
  inputs: {
    scale: number;
    start_at: number;
    end_at: number;
    model: [string, number];
    vae: [string, number];
    image: [string, number];
    mask: [string, number];
    brushnet: [string, number];
    positive: [string, number];
    negative: [string, number];
  };
  class_type: 'BrushNet';
  _meta: {
    title: string;
  };
}

interface CheckpointLoaderSimple {
  inputs: {
    ckpt_name: string;
  };
  class_type: 'CheckpointLoaderSimple';
  _meta: {
    title: string;
  };
}

interface LoadImage {
  inputs: {
    image: string;
  };
  class_type: 'LoadImage';
  _meta: {
    title: string;
  };
}

interface ShowText {
  inputs: {
    text_0: string;
    text: [string, number];
  };
  class_type: 'ShowText|pysssss';
  _meta: {
    title: string;
  };
}

interface CLIPTextEncode {
  inputs: {
    text: [string, number] | string;
    speak_and_recognation: {
      __value__: [boolean, boolean];
    };
    clip: [string, number];
  };
  class_type: 'CLIPTextEncode';
  _meta: {
    title: string;
  };
}

interface LoraLoader {
  inputs: {
    lora_name: string;
    strength_model: number;
    strength_clip: number;
    model: [string, number];
    clip: [string, number];
  };
  class_type: 'LoraLoader';
  _meta: {
    title: string;
  };
}

interface LayerMaskMaskGrow {
  inputs: {
    invert_mask: boolean;
    grow: number;
    blur: number;
    mask: [string, number];
  };
  class_type: 'LayerMask: MaskGrow';
  _meta: {
    title: string;
  };
}

interface ControlNetLoader {
  inputs: {
    control_net_name: string;
  };
  class_type: 'ControlNetLoader';
  _meta: {
    title: string;
  };
}

interface AnyLineArtPreprocessor {
  inputs: {
    merge_with_lineart: string;
    resolution: number;
    lineart_lower_bound: number;
    lineart_upper_bound: number;
    object_min_size: number;
    object_connectivity: number;
    image: [string, number];
  };
  class_type: 'AnyLineArtPreprocessor_aux';
  _meta: {
    title: string;
  };
}

interface ControlNetApplyAdvanced {
  inputs: {
    strength: number;
    start_percent: number;
    end_percent: number;
    positive: [string, number];
    negative: [string, number];
    control_net: [string, number];
    image: [string, number];
    vae: [string, number];
  };
  class_type: 'ControlNetApplyAdvanced';
  _meta: {
    title: string;
  };
}

interface IPAdapterUnifiedLoader {
  inputs: {
    preset: string;
    model: [string, number];
  };
  class_type: 'IPAdapterUnifiedLoader';
  _meta: {
    title: string;
  };
}

interface CLIPVisionLoader {
  inputs: {
    clip_name: string;
  };
  class_type: 'CLIPVisionLoader';
  _meta: {
    title: string;
  };
}

interface IPAdapterAdvanced {
  inputs: {
    weight: number;
    weight_type: string;
    combine_embeds: string;
    start_at: number;
    end_at: number;
    embeds_scaling: string;
    model: [string, number];
    ipadapter: [string, number];
    image: [string, number];
    clip_vision: [string, number];
  };
  class_type: 'IPAdapterAdvanced';
  _meta: {
    title: string;
  };
}

interface LayerUtilityImageBlendAdvance {
  inputs: {
    invert_mask: boolean;
    blend_mode: string;
    opacity: number;
    x_percent: number;
    y_percent: number;
    mirror: string;
    scale: number;
    aspect_ratio: number;
    rotate: number;
    transform_method: string;
    anti_aliasing: number;
    background_image: [string, number];
    layer_image: [string, number];
    layer_mask: [string, number];
  };
  class_type: 'LayerUtility: ImageBlendAdvance';
  _meta: {
    title: string;
  };
}

interface Florence2Run {
  inputs: {
    text_input: string;
    task: string;
    fill_mask: boolean;
    keep_model_loaded: boolean;
    max_new_tokens: number;
    num_beams: number;
    do_sample: boolean;
    output_mask_select: string;
    seed: number;
    speak_and_recognation: {
      __value__: [boolean, boolean];
    };
    image: [string, number];
    florence2_model: [string, number];
  };
  class_type: 'Florence2Run';
  _meta: {
    title: string;
  };
}

interface TextConcatenate {
  inputs: {
    delimiter: string;
    clean_whitespace: 'true' | 'false';
    text_a: [string, number];
    text_b: [string, number];
  };
  class_type: 'Text Concatenate';
  _meta: {
    title: string;
  };
}

interface VAEEncode {
  inputs: {
    pixels: [string, number];
    vae: [string, number];
  };
  class_type: 'VAEEncode';
  _meta: {
    title: string;
  };
}

interface FluxGuidance {
  inputs: {
    guidance: number;
    conditioning: [string, number];
  };
  class_type: 'FluxGuidance';
  _meta: {
    title: string;
  };
}

interface InvertMask {
  inputs: {
    mask: [string, number];
  };
  class_type: 'InvertMask';
  _meta: {
    title: string;
  };
}

interface LoadAndApplyICLightUnet {
  inputs: {
    model_path: string;
    model: [string, number];
  };
  class_type: 'LoadAndApplyICLightUnet';
  _meta: {
    title: string;
  };
}

interface ICLightConditioning {
  inputs: {
    multiplier: number;
    positive: [string, number];
    negative: [string, number];
    vae: [string, number];
    foreground: [string, number];
  };
  class_type: 'ICLightConditioning';
  _meta: {
    title: string;
  };
}

interface DetailTransfer {
  inputs: {
    mode: string;
    blur_sigma: number;
    blend_factor: number;
    target: [string, number];
    source: [string, number];
  };
  class_type: 'DetailTransfer';
  _meta: {
    title: string;
  };
}

interface LayerUtilityImageBlend {
  inputs: {
    invert_mask: boolean;
    blend_mode: string;
    opacity: number;
    background_image: [string, number];
    layer_image: [string, number];
    layer_mask: [string, number];
  };
  class_type: 'LayerUtility: ImageBlend';
  _meta: {
    title: string;
  };
}

interface LightSource {
  inputs: {
    light_position: string;
    multiplier: number;
    start_color: string;
    end_color: string;
    width: [string, number];
    height: [string, number];
    batch_size: number;
  };
  class_type: 'LightSource';
  _meta: {
    title: string;
  };
}

interface LayerUtilityImageScaleByAspectRatio {
  inputs: {
    aspect_ratio: string;
    proportional_width: number;
    proportional_height: number;
    fit: string;
    method: string;
    round_to_multiple: string;
    scale_to_side: string;
    scale_to_length: number;
    background_color: string;
    image: [string, number];
  };
  class_type: 'LayerUtility: ImageScaleByAspectRatio V2';
  _meta: {
    title: string;
  };
}

interface UNETLoader {
  inputs: {
    unet_name: string;
    weight_dtype: string;
  };
  class_type: 'UNETLoader';
  _meta: {
    title: string;
  };
}

interface KSamplerSelect {
  inputs: {
    sampler_name: string;
  };
  class_type: 'KSamplerSelect';
  _meta: {
    title: string;
  };
}

interface BasicScheduler {
  inputs: {
    scheduler: string;
    steps: number;
    denoise: number;
    model: [string, number];
  };
  class_type: 'BasicScheduler';
  _meta: {
    title: string;
  };
}

interface DualCLIPLoader {
  inputs: {
    clip_name1: string;
    clip_name2: string;
    type: string;
    device: string;
  };
  class_type: 'DualCLIPLoader';
  _meta: {
    title: string;
  };
}

interface VAELoader {
  inputs: {
    vae_name: string;
  };
  class_type: 'VAELoader';
  _meta: {
    title: string;
  };
}

interface SamplerCustom {
  inputs: {
    add_noise: boolean;
    noise_seed: number;
    cfg: number;
    model: [string, number] | string;
    positive: [string, number];
    negative: [string, number];
    sampler: [string, number];
    sigmas: [string, number];
    latent_image: [string, number];
  };
  class_type: 'SamplerCustom';
  _meta: {
    title: string;
  };
}

interface LayerMaskBiRefNetUltraV2 {
  inputs: {
    detail_method: string;
    detail_erode: number;
    detail_dilate: number;
    black_point: number;
    white_point: number;
    process_detail: boolean;
    device: string;
    max_megapixels: number;
    image: [string, number];
    birefnet_model: [string, number];
  };
  class_type: 'LayerMask: BiRefNetUltraV2';
  _meta: {
    title: string;
  };
}

interface LayerUtilityImageCombineAlpha {
  inputs: {
    RGB_image: [string, number];
    mask: [string, number];
  };
  class_type: 'LayerUtility: ImageCombineAlpha';
  _meta: {
    title: string;
  };
}

interface PreviewImage {
  inputs: {
    images: [string, number];
  };
  class_type: 'PreviewImage';
  _meta: {
    title: string;
  };
}

interface LayerUtilityImageRemoveAlpha {
  inputs: {
    fill_background: boolean;
    background_color: string;
    RGBA_image: [string, number];
  };
  class_type: 'LayerUtility: ImageRemoveAlpha';
  _meta: {
    title: string;
  };
}

interface GoogleTranslateTextNode {
  inputs: {
    from_translate: string;
    to_translate: string;
    manual_translate: boolean;
    'Manual Trasnlate': string;
    text: string;
    speak_and_recognation: {
      __value__: [boolean, boolean];
    };
  };
  class_type: 'GoogleTranslateTextNode';
  _meta: {
    title: string;
  };
}

interface SaveImage {
  inputs: {
    filename_prefix: string;
    images: [string, number];
  };
  class_type: 'SaveImage';
  _meta: {
    title: string;
  };
}

interface LayerMaskLoadBiRefNetModelV2 {
  inputs: {
    version: string;
  };
  class_type: 'LayerMask: LoadBiRefNetModelV2';
  _meta: {
    title: string;
  };
}

interface EasyImageSize {
  inputs: {
    image: [string, number];
  };
  class_type: 'easy imageSize';
  _meta: {
    title: string;
  };
}

export type ComfyUINode =
  | BrushNetLoader
  | KSampler
  | VAEDecode
  | BrushNet
  | CheckpointLoaderSimple
  | LoadImage
  | ShowText
  | CLIPTextEncode
  | LoraLoader
  | LayerMaskMaskGrow
  | ControlNetLoader
  | AnyLineArtPreprocessor
  | ControlNetApplyAdvanced
  | IPAdapterUnifiedLoader
  | CLIPVisionLoader
  | IPAdapterAdvanced
  | LayerUtilityImageBlendAdvance
  | Florence2Run
  | TextConcatenate
  | VAEEncode
  | FluxGuidance
  | InvertMask
  | LoadAndApplyICLightUnet
  | ICLightConditioning
  | DetailTransfer
  | LayerUtilityImageBlend
  | LightSource
  | LayerUtilityImageScaleByAspectRatio
  | UNETLoader
  | KSamplerSelect
  | BasicScheduler
  | DualCLIPLoader
  | VAELoader
  | SamplerCustom
  | LayerMaskBiRefNetUltraV2
  | LayerUtilityImageCombineAlpha
  | PreviewImage
  | LayerUtilityImageRemoveAlpha
  | GoogleTranslateTextNode
  | SaveImage
  | LayerMaskLoadBiRefNetModelV2
  | EasyImageSize
  | {
      inputs: {
        model: 'microsoft/Florence-2-base';
        precision: 'fp16';
        attention: 'sdpa';
      };
      class_type: 'DownloadAndLoadFlorence2Model';
      _meta: {
        title: '下载并加载 Florence2 模型';
      };
    };

export interface WorkFlowApi {
  [nodeId: string]: ComfyUINode;
}
export const workFlowApi: WorkFlowApi = {
  '45': {
    inputs: {
      brushnet: 'segmentation_XL/diffusion_pytorch_model.safetensors',
      dtype: 'float16',
    },
    class_type: 'BrushNetLoader',
    _meta: {
      title: 'BrushNet加载器',
    },
  },
  '55': {
    inputs: {
      seed: 416864746018382,
      steps: 30,
      cfg: 6,
      sampler_name: 'euler',
      scheduler: 'normal',
      denoise: 1,
      model: ['59', 0],
      positive: ['81', 0],
      negative: ['81', 1],
      latent_image: ['59', 3],
    },
    class_type: 'KSampler',
    _meta: {
      title: 'K采样器',
    },
  },
  '57': {
    inputs: {
      samples: ['55', 0],
      vae: ['61', 2],
    },
    class_type: 'VAEDecode',
    _meta: {
      title: 'VAE解码',
    },
  },
  '59': {
    inputs: {
      scale: 1,
      start_at: 0,
      end_at: 10000,
      model: ['85', 0],
      vae: ['61', 2],
      image: ['255', 0],
      mask: ['71', 0],
      brushnet: ['45', 0],
      positive: ['67', 0],
      negative: ['68', 0],
    },
    class_type: 'BrushNet',
    _meta: {
      title: 'BrushNet',
    },
  },
  '61': {
    inputs: {
      ckpt_name: '真境写真XL Elite KV _ 电商产品摄影海报视觉设计_VisionX ProF.safetensors',
    },
    class_type: 'CheckpointLoaderSimple',
    _meta: {
      title: 'Checkpoint加载器(简易)',
    },
  },
  '62': {
    inputs: {
      image: '20240204_b32e62c9d790762672aaafa698b9a259.jpg',
    },
    class_type: 'LoadImage',
    _meta: {
      title: '加载图像',
    },
  },
  '66': {
    inputs: {
      text_0:
        'Masterpiece, best detail, best picture quality, best quality, realistic, RAW photos, 8k',
      text: ['260', 0],
    },
    class_type: 'ShowText|pysssss',
    _meta: {
      title: '展示文本',
    },
  },
  '67': {
    inputs: {
      text: ['109', 0],
      speak_and_recognation: {
        __value__: [false, true],
      },
      clip: ['69', 1],
    },
    class_type: 'CLIPTextEncode',
    _meta: {
      title: 'CLIP文本编码器',
    },
  },
  '68': {
    inputs: {
      text: 'nsfw,worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art, watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name, blur, blurry, grainy, ugly, asymmetrical, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, text, watermark,\n(smooth material:1.1),(Highly reflective:1.2), (Material reflection:1.2),(nsfw:1.1)',
      speak_and_recognation: {
        __value__: [false, true],
      },
      clip: ['69', 1],
    },
    class_type: 'CLIPTextEncode',
    _meta: {
      title: 'CLIP文本编码器',
    },
  },
  '69': {
    inputs: {
      lora_name: 'SDXL护肤品，化妆品产品摄影_场景图_电商_化妆品产品摄影场景图XL-V1.safetensors',
      strength_model: 0.8,
      strength_clip: 1,
      model: ['61', 0],
      clip: ['61', 1],
    },
    class_type: 'LoraLoader',
    _meta: {
      title: 'LoRA加载器',
    },
  },
  '71': {
    inputs: {
      invert_mask: true,
      grow: 0,
      blur: 2,
      mask: ['255', 1],
    },
    class_type: 'LayerMask: MaskGrow',
    _meta: {
      title: '遮罩扩张',
    },
  },
  '78': {
    inputs: {
      control_net_name: 't2iadapter_sketch_sd15v2.pth',
    },
    class_type: 'ControlNetLoader',
    _meta: {
      title: 'ControlNet加载器',
    },
  },
  '79': {
    inputs: {
      merge_with_lineart: 'lineart_realisitic',
      resolution: 800,
      lineart_lower_bound: 0,
      lineart_upper_bound: 1,
      object_min_size: 36,
      object_connectivity: 1,
      image: ['255', 0],
    },
    class_type: 'AnyLineArtPreprocessor_aux',
    _meta: {
      title: 'AnyLine预处理器',
    },
  },
  '81': {
    inputs: {
      strength: 0.9,
      start_percent: 0,
      end_percent: 1,
      positive: ['59', 1],
      negative: ['59', 2],
      control_net: ['78', 0],
      image: ['79', 0],
      vae: ['61', 2],
    },
    class_type: 'ControlNetApplyAdvanced',
    _meta: {
      title: 'ControlNet应用（旧版高级）',
    },
  },
  '82': {
    inputs: {
      preset: 'PLUS (high strength)',
      model: ['69', 0],
    },
    class_type: 'IPAdapterUnifiedLoader',
    _meta: {
      title: 'IPAdapter加载器',
    },
  },
  '83': {
    inputs: {
      clip_name: 'CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors',
    },
    class_type: 'CLIPVisionLoader',
    _meta: {
      title: 'CLIP视觉加载器',
    },
  },
  '84': {
    inputs: {
      image: '下载.jpg',
    },
    class_type: 'LoadImage',
    _meta: {
      title: '加载图像',
    },
  },
  '85': {
    inputs: {
      weight: 0.7000000000000001,
      weight_type: 'style transfer',
      combine_embeds: 'concat',
      start_at: 0.1,
      end_at: 0.9,
      embeds_scaling: 'V only',
      model: ['82', 0],
      ipadapter: ['82', 1],
      image: ['84', 0],
      clip_vision: ['83', 0],
    },
    class_type: 'IPAdapterAdvanced',
    _meta: {
      title: '应用IPAdapter（高级）',
    },
  },
  '98': {
    inputs: {
      invert_mask: true,
      blend_mode: 'normal',
      opacity: 100,
      x_percent: 50,
      y_percent: 50,
      mirror: 'None',
      scale: 1,
      aspect_ratio: 1,
      rotate: 0,
      transform_method: 'lanczos',
      anti_aliasing: 4,
      background_image: ['112', 0],
      layer_image: ['255', 0],
      layer_mask: ['127', 0],
    },
    class_type: 'LayerUtility: ImageBlendAdvance',
    _meta: {
      title: '混合(高级)',
    },
  },
  '106': {
    inputs: {
      text_input: '',
      task: 'more_detailed_caption',
      fill_mask: true,
      keep_model_loaded: true,
      max_new_tokens: 800,
      num_beams: 3,
      do_sample: true,
      output_mask_select: '',
      seed: 846105767140844,
      speak_and_recognation: {
        __value__: [false, true],
      },
      image: ['84', 0],
      florence2_model: ['108', 0],
    },
    class_type: 'Florence2Run',
    _meta: {
      title: 'Florence2 执行',
    },
  },
  '107': {
    inputs: {
      text_0:
        'The image shows a beautiful outdoor patio area of a two-story house. The patio is made of wooden planks and is surrounded by lush greenery. There are two blue rocking chairs and a small black coffee table in the center of the patio. On the left side of the image, there is a covered patio with a blue sofa and several potted plants. The house has large windows and a balcony with a railing. The sky is overcast and the overall atmosphere is peaceful and inviting.',
      text: ['106', 2],
    },
    class_type: 'ShowText|pysssss',
    _meta: {
      title: '展示文本',
    },
  },
  '108': {
    inputs: {
      model: 'microsoft/Florence-2-base',
      precision: 'fp16',
      attention: 'sdpa',
    },
    class_type: 'DownloadAndLoadFlorence2Model',
    _meta: {
      title: '下载并加载 Florence2 模型',
    },
  },
  '109': {
    inputs: {
      delimiter: ', ',
      clean_whitespace: 'true',
      text_a: ['107', 0],
      text_b: ['66', 0],
    },
    class_type: 'Text Concatenate',
    _meta: {
      title: '文本连锁',
    },
  },
  '110': {
    inputs: {
      text: '',
      speak_and_recognation: {
        __value__: [false, true],
      },
      clip: ['218', 0],
    },
    class_type: 'CLIPTextEncode',
    _meta: {
      title: 'CLIP文本编码器',
    },
  },
  '111': {
    inputs: {
      lora_name: 'XLabs F.1 Realism LoRA_V1.safetensors',
      strength_model: 0.6,
      strength_clip: 1,
      model: ['215', 0],
      clip: ['218', 0],
    },
    class_type: 'LoraLoader',
    _meta: {
      title: 'LoRA加载器',
    },
  },
  '112': {
    inputs: {
      samples: ['221', 0],
      vae: ['220', 0],
    },
    class_type: 'VAEDecode',
    _meta: {
      title: 'VAE解码',
    },
  },
  '116': {
    inputs: {
      guidance: 3.5,
      conditioning: ['121', 0],
    },
    class_type: 'FluxGuidance',
    _meta: {
      title: 'Flux引导',
    },
  },
  '121': {
    inputs: {
      text: ['109', 0],
      speak_and_recognation: {
        __value__: [false, true],
      },
      clip: ['111', 1],
    },
    class_type: 'CLIPTextEncode',
    _meta: {
      title: 'CLIP文本编码器',
    },
  },
  '127': {
    inputs: {
      mask: ['255', 1],
    },
    class_type: 'InvertMask',
    _meta: {
      title: '遮罩反转',
    },
  },
  '129': {
    inputs: {
      pixels: ['57', 0],
      vae: ['220', 0],
    },
    class_type: 'VAEEncode',
    _meta: {
      title: 'VAE编码',
    },
  },
  '131': {
    inputs: {
      preset: 'PLUS (high strength)',
      model: ['140', 0],
    },
    class_type: 'IPAdapterUnifiedLoader',
    _meta: {
      title: 'IPAdapter加载器',
    },
  },
  '132': {
    inputs: {
      clip_name: 'CLIP-ViT-H-14-laion2B-s32B-b79K.safetensors',
    },
    class_type: 'CLIPVisionLoader',
    _meta: {
      title: 'CLIP视觉加载器',
    },
  },
  '133': {
    inputs: {
      weight: 0.5,
      weight_type: 'style transfer',
      combine_embeds: 'concat',
      start_at: 0.1,
      end_at: 1,
      embeds_scaling: 'V only',
      model: ['131', 0],
      ipadapter: ['131', 1],
      image: ['98', 0],
      clip_vision: ['132', 0],
    },
    class_type: 'IPAdapterAdvanced',
    _meta: {
      title: '应用IPAdapter（高级）',
    },
  },
  '135': {
    inputs: {
      samples: ['146', 0],
      vae: ['139', 2],
    },
    class_type: 'VAEDecode',
    _meta: {
      title: 'VAE解码',
    },
  },
  '138': {
    inputs: {
      text: ['109', 0],
      speak_and_recognation: {
        __value__: [false, true],
      },
      clip: ['139', 1],
    },
    class_type: 'CLIPTextEncode',
    _meta: {
      title: 'CLIP文本编码器',
    },
  },
  '139': {
    inputs: {
      ckpt_name: 'PicX_real 真实感_v1.0.safetensors',
    },
    class_type: 'CheckpointLoaderSimple',
    _meta: {
      title: 'Checkpoint加载器(简易)',
    },
  },
  '140': {
    inputs: {
      model_path: 'IC-Light/iclight_sd15_fc.safetensors',
      model: ['139', 0],
    },
    class_type: 'LoadAndApplyICLightUnet',
    _meta: {
      title: '加载ICLight模型',
    },
  },
  '142': {
    inputs: {
      pixels: ['98', 0],
      vae: ['139', 2],
    },
    class_type: 'VAEEncode',
    _meta: {
      title: 'VAE编码',
    },
  },
  '143': {
    inputs: {
      image: ['98', 0],
    },
    class_type: 'easy imageSize',
    _meta: {
      title: '图像尺寸',
    },
  },
  '145': {
    inputs: {
      text: 'nsfw,worst quality, low quality, normal quality, lowres, low details, oversaturated, undersaturated, overexposed, underexposed, grayscale, bw, bad photo, bad photography, bad art, watermark, signature, text font, username, error, logo, words, letters, digits, autograph, trademark, name, blur, blurry, grainy, ugly, asymmetrical, poorly lit, bad shadow, draft, cropped, out of frame, cut off, censored, jpeg artifacts, out of focus, glitch, duplicate, text, watermark,\n(smooth material:1.1),(Highly reflective:1.2), (Material reflection:1.2),(nsfw:1.1)',
      speak_and_recognation: {
        __value__: [false, true],
      },
      clip: ['139', 1],
    },
    class_type: 'CLIPTextEncode',
    _meta: {
      title: 'CLIP文本编码器',
    },
  },
  '146': {
    inputs: {
      seed: 1088295107744232,
      steps: 20,
      cfg: 3,
      sampler_name: 'euler',
      scheduler: 'normal',
      denoise: 1,
      model: ['133', 0],
      positive: ['148', 0],
      negative: ['148', 1],
      latent_image: ['147', 0],
    },
    class_type: 'KSampler',
    _meta: {
      title: 'K采样器',
    },
  },
  '147': {
    inputs: {
      pixels: ['159', 0],
      vae: ['139', 2],
    },
    class_type: 'VAEEncode',
    _meta: {
      title: 'VAE编码',
    },
  },
  '148': {
    inputs: {
      multiplier: 0.185,
      positive: ['138', 0],
      negative: ['145', 0],
      vae: ['139', 2],
      foreground: ['142', 0],
    },
    class_type: 'ICLightConditioning',
    _meta: {
      title: '应用ICLight条件',
    },
  },
  '157': {
    inputs: {
      mode: 'add',
      blur_sigma: 1,
      blend_factor: 1,
      target: ['98', 0],
      source: ['135', 0],
    },
    class_type: 'DetailTransfer',
    _meta: {
      title: '细节迁移',
    },
  },
  '158': {
    inputs: {
      invert_mask: true,
      blend_mode: 'soft_light',
      opacity: 74,
      background_image: ['98', 0],
      layer_image: ['157', 0],
      layer_mask: ['127', 0],
    },
    class_type: 'LayerUtility: ImageBlend',
    _meta: {
      title: '混合',
    },
  },
  '159': {
    inputs: {
      light_position: 'Bottom Light',
      multiplier: 1,
      start_color: '#FFFFFF',
      end_color: '#000000',
      width: ['143', 0],
      height: ['143', 1],
      batch_size: 1,
    },
    class_type: 'LightSource',
    _meta: {
      title: '简易光源',
    },
  },
  '200': {
    inputs: {
      aspect_ratio: 'original',
      proportional_width: 1,
      proportional_height: 1,
      fit: 'letterbox',
      method: 'lanczos',
      round_to_multiple: '8',
      scale_to_side: 'width',
      scale_to_length: 800,
      background_color: '#000000',
      image: ['62', 0],
    },
    class_type: 'LayerUtility: ImageScaleByAspectRatio V2',
    _meta: {
      title: '按宽高比缩放_V2',
    },
  },
  '215': {
    inputs: {
      unet_name: 'FLUX/flux1-dev-fp8.safetensors',
      weight_dtype: 'fp8_e4m3fn',
    },
    class_type: 'UNETLoader',
    _meta: {
      title: 'UNET加载器',
    },
  },
  '216': {
    inputs: {
      sampler_name: 'euler',
    },
    class_type: 'KSamplerSelect',
    _meta: {
      title: 'K采样器选择',
    },
  },
  '217': {
    inputs: {
      scheduler: 'normal',
      steps: 20,
      denoise: 0.25,
      model: ['111', 0],
    },
    class_type: 'BasicScheduler',
    _meta: {
      title: '基础调度器',
    },
  },
  '218': {
    inputs: {
      clip_name1: 't5xxl_fp8_e4m3fn.safetensors',
      clip_name2: 'clip_l.safetensors',
      type: 'flux',
      device: 'default',
    },
    class_type: 'DualCLIPLoader',
    _meta: {
      title: '双CLIP加载器',
    },
  },
  '220': {
    inputs: {
      vae_name: 'FLUX1/ae.safetensors',
    },
    class_type: 'VAELoader',
    _meta: {
      title: 'VAE加载器',
    },
  },
  '221': {
    inputs: {
      add_noise: true,
      noise_seed: 421820604342030,
      cfg: 1,
      model: ['111', 0],
      positive: ['116', 0],
      negative: ['110', 0],
      sampler: ['216', 0],
      sigmas: ['217', 0],
      latent_image: ['129', 0],
    },
    class_type: 'SamplerCustom',
    _meta: {
      title: '自定义采样器',
    },
  },
  '255': {
    inputs: {
      detail_method: 'VITMatte',
      detail_erode: 4,
      detail_dilate: 2,
      black_point: 0.01,
      white_point: 0.99,
      process_detail: false,
      device: 'cuda',
      max_megapixels: 2,
      image: ['200', 0],
      birefnet_model: ['262', 0],
    },
    class_type: 'LayerMask: BiRefNetUltraV2',
    _meta: {
      title: 'BiRefNet Ultra V2',
    },
  },
  '256': {
    inputs: {
      RGB_image: ['259', 0],
      mask: ['255', 1],
    },
    class_type: 'LayerUtility: ImageCombineAlpha',
    _meta: {
      title: '图像合并Alpha',
    },
  },
  '258': {
    inputs: {
      images: ['256', 0],
    },
    class_type: 'PreviewImage',
    _meta: {
      title: '预览图像',
    },
  },
  '259': {
    inputs: {
      fill_background: false,
      background_color: '#000000',
      RGBA_image: ['255', 0],
    },
    class_type: 'LayerUtility: ImageRemoveAlpha',
    _meta: {
      title: '移除Alpha',
    },
  },
  '260': {
    inputs: {
      from_translate: 'auto',
      to_translate: 'en',
      manual_translate: false,
      'Manual Trasnlate': 'Manual Trasnlate',
      text: '杰作，最佳细节，最佳画质，最佳质量，逼真，RAW照片，8k\n',
      speak_and_recognation: {
        __value__: [false, true],
      },
    },
    class_type: 'GoogleTranslateTextNode',
    _meta: {
      title: 'Google Translate Text Node',
    },
  },
  '261': {
    inputs: {
      filename_prefix: 'ComfyUI',
      images: ['158', 0],
    },
    class_type: 'SaveImage',
    _meta: {
      title: '保存图像',
    },
  },
  '262': {
    inputs: {
      version: 'RMBG-2.0',
    },
    class_type: 'LayerMask: LoadBiRefNetModelV2',
    _meta: {
      title: '图层遮罩：加载BiRefNet模型 V2（高级）',
    },
  },
};

// 合成新的工作流 ID
export function createWorkFlowApi(options: {
  inputImage: string;
  backgroundImage: string;
  comfyUIInputImageNodeId: number;
  comfyUIBackgroundImageNodeId: number;
}): WorkFlowApi {
  const { inputImage, backgroundImage, comfyUIInputImageNodeId, comfyUIBackgroundImageNodeId } =
    options;
  // 把对应的节点的 inputs.image 替换对应的路径
  return {
    ...workFlowApi,
    [comfyUIInputImageNodeId]: {
      ...workFlowApi[comfyUIInputImageNodeId],
      inputs: {
        ...workFlowApi[comfyUIInputImageNodeId].inputs,
        image: inputImage,
      },
    },
    [comfyUIBackgroundImageNodeId]: {
      ...workFlowApi[comfyUIBackgroundImageNodeId],
      inputs: {
        ...workFlowApi[comfyUIBackgroundImageNodeId].inputs,
        image: backgroundImage,
      },
    },
  };
}
